<div class="opts">
  <%= if has_starred?(user: @current_user, topic: @topic) do %>
    <%= link to: topic_path(@conn, :unstar, @topic), method: :post, class: "likeable active" do %>
      <i class="fa fa-heart"></i>
      <span><%= gettext "%{star_count} stars", star_count: @topic.star_count %></span>
    <% end %>
  <% else %>
    <%= link to: topic_path(@conn, :star, @topic), method: :post, class: "likeable deactive" do %>
      <i class="fa fa-heart"></i>
      <span><%= gettext "%{star_count} stars", star_count: @topic.star_count %></span>
    <% end %>
  <% end %>

  <%= if has_collected?(@current_user, @topic) do %>
    <%= link to: topic_path(@conn, :uncollection, @topic), method: :post, class: "bookmark active" do %>
      <i class="fa fa-bookmark"></i> <%= gettext "Uncollection" %>
    <% end %>
  <% else %>
    <%= link to: topic_path(@conn, :collection, @topic), method: :post, class: "bookmark" do %>
      <i class="fa fa-bookmark"></i> <%= gettext "Collection" %>
    <% end %>
  <% end %>

  <%# 只有管理员可以设置「置顶」或「加精」 %>
  <%= if @current_user && @current_user.is_admin do %>
    <%= if @topic.suggested_at do %>
      <%= link to: topic_path(@conn, :unsuggest, @topic), method: :post do %>
        <i class="fa fa-angle-double-down"></i> <%= gettext "Unpin" %>
      <% end %>
    <% else %>
      <%= link to: topic_path(@conn, :suggest, @topic), method: :post do %>
        <i class="fa fa-angle-double-up"></i> <%= gettext "Pin" %>
      <% end %>
    <% end %>

    <%= if @topic.type == :featured do %>
      <%= link to: topic_path(@conn, :normal, @topic), method: :post, title: "Unmark featured" do %>
        <i class="fa fa-diamond"></i> <%= gettext "Unmark featured" %>
      <% end %>
    <% else %>
      <%= link to: topic_path(@conn, :excellent, @topic), method: :post, title: "Mark featured" do %>
        <i class="fa fa-diamond"></i> <%= gettext "Mark featured" %>
      <% end %>
    <% end %>
  <% end %>

  <%# FIXME 后续考虑权限控制 %>
  <%= if @current_user && @current_user.id == @topic.user_id do %>
    <span class="pull-right opts">
      <%= if @topic.closed_at do %>
        <%= link "", to: topic_path(@conn, :open, @topic), method: :post, title: "Reopen", class: "fa fa-undo" %>
      <% else %>
        <%= link "", to: topic_path(@conn, :close, @topic), method: :post, title: "Closed", class: "fa fa-check" %>
      <% end %>
      <%= link "", to: topic_path(@conn, :edit, @topic), title: "Change Topic", class: "fa fa-pencil" %>
      <%= link "", to: topic_path(@conn, :delete, @topic), title: "Delete Topic", class: "fa fa-trash", method: :delete, data: [confirm: "Are you sure?"] %>
    </span>
  <% end %>
</div>